if holder1<2 then select line maxlines of card field (holder1+1) else select line maxlines+1 of card field (holder1-1)
end enterinfield
-- part 23 (field)
-- low flags: 00
-- high flags: 4007
-- rect: left=173 top=93 right=253 bottom=274
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Date
-- part 24 (field)
-- low flags: 00
-- high flags: 4007
-- rect: left=257 top=93 right=253 bottom=361
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Weight
----- HyperTalk script -----
on mouseWithin
put the number of lines of card field "weight" into maxlines
put the scroll of card field "weight" into align
put round(align/16) into invis
if maxlines-invis = 10 then select line maxlines+1 of card field "weight"
if maxlines-invis = 10 then select line maxlines+1 of card field "date"
else set the scroll of card field "date" to align
end mouseWithin
-- part 2 (field)
-- low flags: 81
-- high flags: 2002
-- rect: left=135 top=28 right=224 bottom=443
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 14
-- style flags: 0
-- line height: 18
-- part name: About
----- HyperTalk script -----
on mouseUp
hide card field "About"
end mouseUp
-- part 17 (button)
-- low flags: 00
-- high flags: 8006
-- rect: left=16 top=59 right=77 bottom=169
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Preferred lbs/week
----- HyperTalk script -----
on mouseUp
put line 2 of card field "y" into y
put line 2 of card field "wT now" into wtNow
ask "Preferred weight loss per week ? "
put it into wlpw
put the date into date1
convert date1 to seconds
put (wtNow-y)/wlpw into weeks
put round(weeks*7)*24*60*60 into seconds
put date1 + seconds into date2
convert date2 to abbr date
put "No. of weeks = " & round(weeks*10)*.1 &" " & "Date = " & date2
end mouseUp
-- part 19 (button)
-- low flags: 00
-- high flags: 8006
-- rect: left=16 top=78 right=99 bottom=141
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Preferred Date
----- HyperTalk script -----
on mouseUp
put line 2 of card field "y" into y
put line 2 of card field "wT now" into wtNow
ask "Preferred Date ? "
put it into date2
put the date into date1
convert date1 to seconds
convert date2 to seconds
put date2-date1 into seconds
put wtNow-y into wtLoss
put "lbs/week = " & round(wtLoss/seconds*60*60*24*7*10)*.1
end mouseUp
-- part 22 (button)
-- low flags: 80
-- high flags: A003
-- rect: left=401 top=55 right=74 bottom=491
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Enter Data
----- HyperTalk script -----
on mouseUp
hide card button "calories"
hide card button "Home"
Hide card button "Enter Data"
show card button "Get Equation"
hide card button "view graph"
hide background button "reset"
hide card button "plot it"
hide card button "calculate"
hide card field "Equation"
hide card field "twlp"
hide card field "Target Date"
hide card field "f1"
hide card field "f2"
hide card field "f3"
hide card field "f4"
hide card field "f5"
hide card field "f6"
hide card field "f7"
hide card field "f8"
hide card field "wtl"
hide card field "weeks"
hide card field "awl"
hide card field "wt loss"
hide card field "WOD"
hide card field "mean loss"
show card button "mask1"
show card button "mask2"
show card button "mask3"
hide card field "y"
hide card field "wt now"
show card field "title1"
show card field "title2"
show card field "Date"
show card field "Weight"
show card button "Store Data"
show card button "Retrieve Data"
show card button "Exchange Data"
show card button "clear data"
show card button "Check Errors"
end mouseUp
-- part 25 (field)
-- low flags: 00
-- high flags: 0002
-- rect: left=173 top=77 right=94 bottom=258
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: Title1
-- part 26 (field)
-- low flags: 00
-- high flags: 0002
-- rect: left=257 top=77 right=94 bottom=361
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: Title2
-- part 27 (field)
-- low flags: 80
-- high flags: 2000
-- rect: left=175 top=68 right=87 bottom=371
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 2
-- text size: 10
-- style flags: 0
-- line height: 13
-- part name: Equation
-- part 29 (field)
-- low flags: 80
-- high flags: 2004
-- rect: left=43 top=113 right=147 bottom=178
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 2
-- text size: 10
-- style flags: 256
-- line height: 13
-- part name: Wt now
-- part 28 (field)
-- low flags: 80
-- high flags: 2004
-- rect: left=175 top=113 right=147 bottom=325
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 2
-- text size: 10
-- style flags: 256
-- line height: 13
-- part name: y
-- part 31 (button)
-- low flags: 00
-- high flags: 0001
-- rect: left=361 top=50 right=293 bottom=495
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Mask1
-- part 32 (button)
-- low flags: 00
-- high flags: 0001
-- rect: left=171 top=270 right=325 bottom=498
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Mask2
-- part 30 (button)
-- low flags: 00
-- high flags: 0001
-- rect: left=13 top=36 right=321 bottom=170
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Mask3
-- part 33 (button)
-- low flags: 80
-- high flags: 8003
-- rect: left=219 top=36 right=55 bottom=310
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Calculate
----- HyperTalk script -----
on mouseUp
hide background button "Reset"
put empty into r
get the visible of card button "view graph"
if it is true then hide card button "plot it" else show card button "plot it"
put card field "date1" into date1
put card field "weight1" into weight1
put card field "weight2" into weight2
ask "What is Target Weight(lbs) ? "
put it into r
if r is empty then get line 2 of card field "y"
if r is empty then put it into line 2 of card field "y" else put r into line 2 of card field "y"
put line 1 of card field "Equation" into equation
put offset ("e",Equation) into divider1
put offset (")",Equation) into divider2
put char 3 to divider1-2 of equation into a
put char divider1+4 to divider2-3 of equation into b
put line 2 of card field "y" into y
put round(Ln(y/a)/b) into days
put the date into date3
convert date1 to seconds
convert date3 to seconds
put (date3 - date1)/60/60/24 into period
put (round(period/7*10))*.1 into card field "wod"
put (round((days - period)/0.7))*.1 into card field "Weeks"
put date1 + days * 60 * 60 * 24 into date2
convert date2 to abbr date
put date2 into line 2 of card field "Target Date"
put round (weight1-y) into line 2 of card field "twlp"
put weight1-weight2 into card field "wt Loss"
put (weight1-weight2)/period*7 into meanloss
put round (meanloss*10)*.1 into card field "Mean Loss"
put weight2-y into card field "wtl"
put round((weight2-y)/((Days-period)/7)*10)*.1 into card field "AWL"
end mouseUp
-- part 60 (field)
-- low flags: 80
-- high flags: 0004
-- rect: left=276 top=193 right=214 bottom=453
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: f6
-- part 59 (field)
-- low flags: 80
-- high flags: 0004
-- rect: left=276 top=211 right=232 bottom=453
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: f7
-- part 35 (field)
-- low flags: 80
-- high flags: 0004
-- rect: left=450 top=193 right=214 bottom=489
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: Wt Loss
-- part 34 (field)
-- low flags: 80
-- high flags: 0004
-- rect: left=450 top=211 right=231 bottom=489
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: WOD
-- part 57 (field)
-- low flags: 80
-- high flags: 0004
-- rect: left=25 top=193 right=214 bottom=203
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: f2
-- part 37 (field)
-- low flags: 80
-- high flags: 0004
-- rect: left=199 top=193 right=214 bottom=244
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: wtl
-- part 55 (field)
-- low flags: 80
-- high flags: 0004
-- rect: left=25 top=211 right=231 bottom=202
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: f3
-- part 54 (field)
-- low flags: 80
-- high flags: 0004
-- rect: left=25 top=228 right=248 bottom=202
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: f4
-- part 38 (field)
-- low flags: 80
-- high flags: 0004
-- rect: left=199 top=211 right=231 bottom=244
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: weeks
-- part 61 (field)
-- low flags: 80
-- high flags: 0004
-- rect: left=276 top=228 right=248 bottom=453
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: f8
-- part 36 (field)
-- low flags: 80
-- high flags: 0004
-- rect: left=450 top=228 right=248 bottom=489
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: Mean Loss
-- part 58 (field)
-- low flags: 80
-- high flags: 2004
-- rect: left=322 top=113 right=147 bottom=480
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 10
-- style flags: 256
-- line height: 13
-- part name: twlp
-- part 42 (field)
-- low flags: 80
-- high flags: 0004
-- rect: left=168 top=269 right=306 bottom=339
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: Target Date
-- part 43 (field)
-- low flags: 80
-- high flags: 0004
-- rect: left=199 top=228 right=248 bottom=244
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: AWL
-- part 64 (field)
-- low flags: 80
-- high flags: 0004
-- rect: left=62 top=169 right=188 bottom=205
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 12
-- style flags: 16640
-- line height: 16
-- part name: f1
-- part 62 (field)
-- low flags: 80
-- high flags: 0004
-- rect: left=311 top=169 right=188 bottom=454
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 12
-- style flags: 16640
-- line height: 16
-- part name: f5
-- part 65 (button)
-- low flags: 80
-- high flags: A003
-- rect: left=221 top=87 right=106 bottom=312
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Plot it
----- HyperTalk script -----
on mouseUp
set cursor to busy
hide background button "reset"
hide card button "instructions"
hide card button "calories"
hide card button "home"
hide card field "title"
show card field "message2"
wait 300
set lockscreen to true
push card
hide card button "plot it"
hide card button "preferred lbs/week"
hide card button "preferred date"
hide card button "calculate"
hide card button "enter data"
hide card button "home"
hide card field "wt now"
hide card field "y"
hide card field "twlp"
hide card field "f1"
hide card field "f5"
hide card field "f2"
hide card field "wtl"
hide card field "weeks"
hide card field "f4"
hide card field "f3"
hide card field "AWL"
hide card field "f6"
hide card field "f7"
hide card field "f8"
hide card field "wt loss"
hide card field "wod"
hide card field "mean loss"
hide card field "target date"
put card field "date1" into date1
put card field "date2" into date2
put card field "a" into a
put card field "b" into b
put card field "count1" into count1
put card field "count2" into count2
put card field "v" into v
put card field "weight1" into weight1
put card field "weight2" into weight2
put empty into xA
put empty into xB
put empty into yA
put empty into yB
put empty into maxWeight
put empty into minWeight
put line 2 of card field "y" into TW
put weight1 into maxWeight
put weight1 into minWeight
put empty into count
put (LN(TW)-v)/b into dateFinal
if dateFinal>365 then put (date2 - date1)/60/60/24 into dateFinal
if b = 0 then put (date2 - date1)/60/60/24 into dateFinal
put dateFinal into xRange
put maxWeight-TW into yRange
put 420/xRange into xFactor
put 260/yRange into yFactor
hide card field "message2"
set lockScreen to false
hide background field "mask7"
hide background button "mask5"
put empty into count
repeat with count = count1+1 to count2
put line count-1 of card field "Date" into dateA
put line count of card field "Date" into dateB
convert dateA to seconds
convert dateB to seconds
put (dateA - date1)/60/60/24 into xA
put (dateB - date1)/60/60/24 into xB
put 51 + (xA * xFactor) into xA
put 51 + (xB * xFactor) into xB
put line count-1 of card field "Weight" into yA
put line count of card field "Weight" into yB
put 311 - ((yA-TW) * yFactor) into yA
put 311 - ((yB-TW) * yFactor) into yB
choose line tool
set lineSize to 2
drag from round (xA), round (yA) to round (xB), round (yB)
choose browse tool
end repeat
Choose line tool
set lineSize to 1
put empty into I
put 0 into x1
put round (xRange) into x2
hide background button "mask6"
repeat with x = x1 to x2
put I + 1 into I
put 311 - (((a * exp (b * x))-TW) * yFactor) into y
if I > 1 then put 51 + ((x-1) * xFactor) into u
if I > 1 then put 51 + (x * xFactor) into p
if I > 1 then put 311 - (((a * exp (b * (x-1)))-TW) * yFactor) into k
If I > 1 then drag from round (u), round (k) to round (p), round (Y)
end repeat
set lockscreen to true
show background button "mask5"
show background button "mask6"
show background field "mask7"
show card button "view graph"
show card button "preferred lbs/week"
show card button "preferred date"
show card button "calculate"
show card button "enter data"
show card button "home"
show card field "title"
show card field "wt now"
show card field "y"
show card field "twlp"
show card field "f1"
show card field "f5"
show card field "f2"
show card field "wtl"
show card field "weeks"
show card field "f4"
show card field "f3"
show card field "AWL"
show card field "f6"
show card field "f7"
show card field "f8"
show card field "wt loss"
show card field "wod"
show card field "mean loss"
show card field "target date"
doMenu "Select all"
doMenu "Cut Picture"
go next card
doMenu "select All"
doMenu "clear picture"
domenu "Paste Picture"
pop card
doMenu "Background"
doMenu "select All"
doMenu "Copy Picture"
doMenu "Background"
go next card
doMenu "Paste Picture"
doMenu "Transparent"
choose browse tool
set lockscreen to false
end mouseUp
-- part 66 (field)
-- low flags: 80
-- high flags: 0001
-- rect: left=15 top=16 right=326 bottom=494
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 12
-- style flags: 22784
-- line height: 16
-- part name: Message
-- part 67 (button)
-- low flags: 80
-- high flags: A003
-- rect: left=219 top=87 right=106 bottom=315
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: View Graph
----- HyperTalk script -----
on mouseUp
hide background button "reset"
hide card button "instructions"
push card
visual effect dissolve slowly
go next card
end mouseUp
-- part 68 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=37 top=56 right=79 bottom=128
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Clear Data
----- HyperTalk script -----
on mouseUp
answer "delete data on screen ?" with "yes" or "No"
if it is "no" then exit mouseUp
select text of card field "date"
doMenu "Clear Text"
select text of card field "weight"
doMenu "Clear Text"
end mouseUp
-- part 72 (button)
-- low flags: 00
-- high flags: 2005
-- rect: left=174 top=77 right=95 bottom=193
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Check Errors
----- HyperTalk script -----
on mouseUp
set cursor to busy
put empty into count
put number of lines of card field date into maxLines
repeat with count = 1 to maxLines
put count + 1 into counts
put line count of card field "date" into dates
put line counts of card field "date" into datess
if datess is empty then put dates into datess
convert dates to seconds
convert datess to seconds
put abs(datess - dates) into dif
if dif > 60 * 60 * 24 * 28 then put "Dates greater than 1 month apart in lines" && count & "," && counts
put line count of card field "weight" into w1
put line counts of card field "weight" into w2
if w2 is empty then put w1 into w2
put abs (w1 - w2) into wdif
if wdif > 10 then put "greater than 10 lbs between lines" && count & "," && counts
if dif > 60 * 60 * 24 * 28 then select line counts of card field "date"
if wdif > 10 then select line counts of card field "weight"
if wdif > 10 then put the scroll of card field "weight" into align
if wdif > 10 then set the scroll of card field "Date" to align
if wdif > 10 then exit repeat
if dif > 60 * 60 * 24 * 28 then put the scroll of card field "date" into align
if dif > 60 * 60 * 24 * 28 then set the scroll of card field "weight" to align
if dif > 60 * 60 * 24 * 28 then exit repeat
end repeat
if dif > 60 * 60 * 24 * 28 then answer "Better Re-check!!"
if wdif > 10 then answer "Better Re-check!!"
end mouseUp
-- part 73 (field)
-- low flags: 80
-- high flags: 0000
-- rect: left=48 top=80 right=98 bottom=121
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Date1
-- part 74 (field)
-- low flags: 80
-- high flags: 0000
-- rect: left=47 top=100 right=118 bottom=120
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Date2
-- part 75 (field)
-- low flags: 80
-- high flags: 0000
-- rect: left=47 top=121 right=139 bottom=120
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: a
-- part 76 (field)
-- low flags: 80
-- high flags: 0000
-- rect: left=47 top=142 right=160 bottom=120
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: b
-- part 77 (field)
-- low flags: 80
-- high flags: 0000
-- rect: left=47 top=165 right=183 bottom=120
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: v
-- part 78 (field)
-- low flags: 80
-- high flags: 0000
-- rect: left=47 top=187 right=205 bottom=120
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: count1
-- part 81 (field)
-- low flags: 80
-- high flags: 0000
-- rect: left=47 top=207 right=225 bottom=120
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: count2
-- part 82 (field)
-- low flags: 80
-- high flags: 0000
-- rect: left=46 top=229 right=247 bottom=119
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: weight1
-- part 83 (field)
-- low flags: 80
-- high flags: 0000
-- rect: left=46 top=250 right=268 bottom=119
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: weight2
-- part 85 (button)
-- low flags: 80
-- high flags: 0000
-- rect: left=454 top=19 right=47 bottom=491
-- title width / last selected line: 0
-- icon id / first selected line: 1011 / 1011
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Home
----- HyperTalk script -----
on mouseUp
go home
end mouseUp
-- part 86 (button)
-- low flags: 00
-- high flags: 0005
-- rect: left=0 top=3 right=15 bottom=16
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: quit
----- HyperTalk script -----
on mouseUp
doMenu "quit Hypercard"
end mouseUp
-- part 87 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=391 top=55 right=76 bottom=492
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Get Equation
----- HyperTalk script -----
on mouseUp
set cursor to busy
put empty into I
put empty into totx
put empty into totz
put empty into totxx
put empty into totxz
put empty into totzz
put empty into a
put empty into b
put empty into v
put empty into count1
put empty into count2
repeat
put count1+1 into count1
put line count1 of card field "date" into date
if date is not empty then exit repeat
if count1>10 then put "resetting Data"
if count1>10 then exit repeat
end repeat
repeat
put count2+1 into count2
if count1>10 then exit repeat
put line count2 of card field "date" into date
if date is empty then exit repeat
end repeat
put count2-1 into count2
put line count1 of card field "date" into date1
put line count2 of card field "date" into date2
convert date1 to seconds
convert date2 to seconds
put empty into count
if count2 - count1 < 2 then answer "require at least 3 data pairs"
if count2 - count1 < 2 then put empty into card field "equation"
if count2 - count1 < 2 then show card button "home"
if count2 - count1 < 2 then exit mouseUp
hide card button "Home"
hide background button "reset"
hide card button "Get Equation"
hide card button "clear data"
hide card button "Store Data"
hide card button "Retrieve Data"
hide card button "Exchange Data"
hide card button "Check Errors"
hide card field "title1"
hide card field "title2"
hide card field "Date"
hide card field "Weight"
hide card button "instructions"
if count2 > 10 then show card field "message"
set lockscreen to true
show card button "Home"
show card button "Enter Data"
show card button "Calculate"
hide card button "Mask1"
hide card button "Mask2"
hide card button "Mask3"
show card field "y"
show card field "wt now"
show card field "twlp"
show card field "Target Date"
show card field "f1"
show card field "f2"
show card field "f3"
show card field "f4"
show card field "f5"
show card field "f6"
show card field "f7"
show card field "f8"
show card field "wtl"
show card field "weeks"
show card field "awl"
show card field "wt loss"
show card field "WOD"
show card field "mean loss"
repeat with count = count1 to count2
if count1>10 then exit repeat
put line count of card field "weight" into y
if count = count1 then put line count of card field "weight" into weight1
if count = count2 then put line count of card field "weight" into weight2
put line count of card field "date" into dates
put I + 1 into I
convert dates to seconds
put (dates - date1)/60/60/24 into x
put totx + x into totx
put LN (y) into z
put totzz + z * z into totzz
put totz + z into totz
put totxx + x * x into totxx
put totxz + x * z into totxz
end repeat
put I into n
put (n * totxz - totx * totz)/(n * totxx - totx * totx) into b
put (totz/n - b * totx/n) into v
put exp(v) into a
put (n*totxz-totx*totz)/sqrt((n*totxx-totx*totx)*(n*totzz-totz*totz)) into r
put "y=" & a & "*exp(" & b & "*X)" into card field "Equation"
if count1>10 then put empty into card field "Equation"
put weight2 into line 2 of card field "wt Now"
put date1 into card field "Date1"
put date2 into card field "date2"
put a into card field "a"
put b into card field "b"
put v into card field "v"
put count1 into card field "count1"
put count2 into card field "count2"
put weight1 into card field "weight1"
put weight2 into card field "weight2"
hide card field "date1"
hide card field "date2"
hide card field "a"
hide card field "b"
hide card field "v"
hide card field "count1"
hide card field "count2"
hide card field "weight1"
hide card field "weight2"
hide card field "equation"
show card button "instructions"
show card button "calories"
hide card field "message"
set lockscreen to false
if -r<= 0.9 then put "Regular dieting/exercise required!!--r is only " && -(round (abs(r)*1000))*.001
if -r<=0.9 then wait 240
if -r<=0.9 then doMenu "message"
if -r>0.9 then put "steady weight loss being made!!--r is high at" && -(round(abs(r)*1000))*.001
if -r>0.9 then wait 240
if -r>0.9 then doMenu "message"
end mouseUp
-- part 89 (field)
-- low flags: 00
-- high flags: 0000
-- rect: left=205 top=14 right=34 bottom=351
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 12
-- style flags: 23808
-- line height: 16
-- part name: Title
-- part 90 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=35 top=89 right=111 bottom=135
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Store Data
----- HyperTalk script -----
on mouseUp
answer "save data on screen and clear fields?" with "yes" or "No"
if it is "no" then exit mouseUp
put last char of card field "Title" into I
if I=1 then put 2 into I else put 1 into I
put I into last char of card field title
get card field "date"
put it into card field "store date"
get card field "weight"
put it into card field "store weight"
select text of card field "date"
doMenu "Clear Text"
select text of card field "weight"
doMenu "Clear Text"
end mouseUp
-- part 91 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=33 top=120 right=141 bottom=136
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Retrieve Data
----- HyperTalk script -----
on mouseUp
answer "replace data on screen with stored data ?" with "yes" or "No"
if it is "no" then exit mouseUp
put last char of card field "Title" into I
if I=1 then put 2 into I else put 1 into I
put I into last char of card field title
get card field "store date"
put it into card field "date"
get card field "store weight"
put it into card field "weight"
end mouseUp
-- part 92 (field)
-- low flags: 80
-- high flags: 0007
-- rect: left=177 top=286 right=317 bottom=313
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Store Date
-- part 93 (field)
-- low flags: 80
-- high flags: 0007
-- rect: left=177 top=286 right=317 bottom=313
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Store Weight
-- part 98 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=35 top=150 right=172 bottom=135
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Exchange Data
----- HyperTalk script -----
on mouseUp
answer "exchange screen data with stored data ?" with "yes" or "No"
if it is "no" then exit mouseUp
put last char of card field "Title" into I
if I=1 then put 2 into I else put 1 into I
put I into last char of card field title
get card field "date"
put it into card field "exchange date"
get card field "weight"
put it into card field "exchange weight"
get card field "store date"
put it into card field "date"
get card field "store weight"
put it into card field "weight"
get card field "exchange date"
put it into card field "store date"
get card field "exchange weight"
put it into card field "store weight"
end mouseUp
-- part 99 (field)
-- low flags: 80
-- high flags: 0007
-- rect: left=221 top=255 right=286 bottom=343
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Exchange Date
-- part 100 (field)
-- low flags: 80
-- high flags: 0007
-- rect: left=220 top=255 right=286 bottom=342
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Exchange Weight
-- part 101 (field)
-- low flags: 80
-- high flags: 0001
-- rect: left=15 top=16 right=326 bottom=494
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 12
-- style flags: 22784
-- line height: 16
-- part name: Message2
-- part 104 (field)
-- low flags: 80
-- high flags: 0007
-- rect: left=15 top=17 right=326 bottom=495
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Instructions
-- part 105 (button)
-- low flags: 80
-- high flags: 8006
-- rect: left=16 top=16 right=32 bottom=121
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Instructions
----- HyperTalk script -----
on mouseUp
hide card button "instructions"
hide card button "calories"
show card field "instructions"
show card button "OK"
end mouseUp
-- part 106 (button)
-- low flags: 80
-- high flags: 8003
-- rect: left=367 top=29 right=51 bottom=467
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: OK
----- HyperTalk script -----
on mouseUp
hide card field "instructions"
hide card button "OK"
show card button "instructions"
show card button "calories"
end mouseUp
-- part 107 (field)
-- low flags: 80
-- high flags: 4002
-- rect: left=29 top=35 right=235 bottom=201
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: TableM
-- part 108 (field)
-- low flags: 80
-- high flags: 4002
-- rect: left=29 top=34 right=234 bottom=201
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: TableF
-- part 109 (button)
-- low flags: 80
-- high flags: 8006
-- rect: left=16 top=33 right=53 bottom=94
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Calories
----- HyperTalk script -----
on mouseUp
put empty into count
put empty into row
put empty into age
put empty into weight
put empty into ages
put empty into w
ask "Today's weight ?"
put it into wtNow
ask "Your Age (20-60) ?"
put it into "age"
if age <20 then answer "ages 20-60 only!"
if age <20 then exit mouseUp
if age >60 then answer "ages 20-60 only!"
if age >60 then exit mouseUp
if age <=35 then put 20 into age
if age >35 then
if age <= 50 then put 40 into age
end if
if age >50 then
if age <= 60 then put 60 into age
end if
answer "sex" with "male" or "female"
put it into sex
if sex is "female" then ask "target weight (100-170lbs) ?" else ask "target weight (100-200lbs) ?"
put it into y
put round((y/10))*10 into weight
if sex is "female" and weight <100 then answer "weight too low!"
if sex is "male" and weight <100 then answer "weight too low!"
if sex is "female" and weight >200 then answer "weight too high!"
if sex is "female" and weight >170 then answer "weight too high!"
if sex is "female" and weight <100 then exit mouseUp
if sex is "male" and weight <100 then exit mouseUp
if sex is "female" and weight >170 then exit mouseUp
if sex is "male" and weight >200 then exit mouseUp
repeat with count=1 to 11
if sex is "male" then put item 1 of line count of card field "TableM" into w
if sex is "female" then put item 1 of line count of card field "tableF" into w
if w=weight then exit repeat
end repeat
repeat with row=2 to 4
put item row of line 1 of card field "TableM" into ages
if ages=age then exit repeat
end repeat
if sex is "male" then put item row of line count of card field "TableM" into Cal
if sex is "female" then put item row of line count of card field "TableF" into Cal
ask "Target Date (mm/dd/yy) ?"
put it into TDate
convert Tdate to seconds
put the date into date1
convert date1 to seconds
put Tdate-date1 into time
put time/60/24/60 into days
put wtnow - y into lbs
put lbs/days into ppd
put cal-ppd*3600 into cals
if ppd*3600>cal then answer "Impossible--or lots of excercise required!!"
if ppd*3600>cal then exit mouseUp
if ppd<0 then answer "Impossible--or lots of excercise required!!"
if ppd<0 then exit mouseUp
put "lbs/day ="&& (round (ppd*10))*.1 && " cals/day =" && round (cals) && " cals to maintain weight =" && Cal
set lockscreen to true
answer "Not many calories huh!!!"
set lockscreen to false
doMenu "message"
end mouseUp
-- part contents for card part 2
----- text -----
HyperCalc, by Dan Winkler
Change any number in the first column, or equation in the second column, then click outside the field to recalculate. For each field, the first line should be the name; the second line a value; the third line an optional equation.
any comments/questions-- write: 1010 Highland Avenue
Hendersonville, NC, 28739
please send a $2.00 donation if you like this stack.
Stack is useful for those monitoring their weight loss during dieting.
--it's great if your trying to win a weight-loss bet!!
By entering the date (in mm/dd/yy format; e.g. 10/10/88) into the date field, and your weight into the weight field, the program fits an exponential curve to the data points ( if you stick to a diet plan then your weight loss will probably be exponential; i.e. weight loss rate gets smaller as you lose weight). From this curve, the date by which you will be at a given weight ("target weight") is estimated.
A graph of the percentage of the weight loss required to reach the target weight is plotted against the percentage of the time required to reach the target weight; e.g. 50% weight means that you have lost half of the total weight loss that you want to lose, and 50% date means that you are half way through the diet. Because the curve is an exponential you will have lost half the total weight loss desired before the diet is half way through.
Most of the buttons are self explanatory and are only visible when they can achieve something; e.g. a "graph plot" button is pressed when you want to plot the data. After the data is plotted, this button disappears and replaced by a "view graph" button.
Using this Program.
1. Press the "enter data" button and enter the date/weight data into the appropriate fields. Note, after entering the first date, press the "enter key" (this automatically moves to the last line of the next field). To enter more data after the scrolling field is full, drag the scroll bar to the bottom and an extra line is automatically added for data entry.
2. After the data has been entered, press the get "equation button".
3. Next, press the "plot it" button if you want a graph plotting (press the "print" icon to print the graph, or the "return" icon to get back to the calculation buttons)
4. If you plotted a graph and are back at the calculation buttons, then you can view the graph by pressing the "view graph" button"
5. You can get the target date after 2. or after 3., by pressing the "calculation" button (this is only visible when you can calculate something).
6. At any time it is visible, you can press the "preferred lbs/week" button. This asks you for the weight you want to lose each week and then calculates the date at which you will reach your target weight.
7. Similarly to 6. you can press the "preferred date" button. This calculates the weight loss per week required to get down to the target weight by a given date.
8. Similarly to 6. you can press the "Calories" button. This calculates the number of calories you should be eating to get down to the target weight in a specified time. Of course, the calorific values given are only estimates, and will be higher for an active person or lower for a sedatory person. In addition, the calories required to maintain the target weight are also given.
Features
• if the system crashes or the computer is turned off accidentally while executing the stack, a reset button is visible on re-opening the stack. On pressing, this button resets the buttons and fields, but leaves the previous data intact.
• the data in the fields can be cleared, stored (1 set only!) or exchanged for previously stored data. This is ideal for 1 or 2 users.
• by pressing the check box at the top left hand side of the "date" field after the data has been entered, any suspect data is highlighted, and the line number given; e.g. a weight difference of more than 10lbs, or a date difference of more than 1 month from the previous line, will be selected.
• the "goodness of fit" of the exponential curve to the data is measured and shown in the message box. The correlation coefficient, r, is used as this measure, and ranges from -1 t0 +1. A value of -1 indicates a perfect fit of the exponential decay curve to the data, whereas 0 indicates no fit at all. A value greater than 0.8 means that the program shoukd give a reasonable estimate of the target date.
• the data entry fields are automatically aligned after the scroll bar has been moved.